// @ts-ignore
import { api } from '@/utils/api';

/** 此处后端没有提供注释 POST /captcha/check */
export async function captchaCheck(
  body: BASE.Data,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.ApiResponseObject>;

export async function captchaCheck(
  body: BASE.Data,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.ApiResponseObject>>;

export async function captchaCheck(
  body: BASE.Data,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.ApiResponseObject>;

export async function captchaCheck(body: BASE.Data, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.ApiResponseObject>(`/app/captcha/check`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.ApiResponseObject>(`/app/captcha/check`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 此处后端没有提供注释 POST /captcha/get */
export async function captchaGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.captchaGetParams,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.CaptchaResponseImageCaptchaVO>;

export async function captchaGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.captchaGetParams,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.CaptchaResponseImageCaptchaVO>>;

export async function captchaGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.captchaGetParams,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.CaptchaResponseImageCaptchaVO>;

export async function captchaGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: BASE.captchaGetParams,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.CaptchaResponseImageCaptchaVO>(`/app/captcha/get`, {
      method: 'POST',
      params: {
        ...params
      },
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.CaptchaResponseImageCaptchaVO>(`/app/captcha/get`, {
    method: 'POST',
    params: {
      ...params
    },
    ...(options || {})
  });
}
